package Demo16_30.Test19;

/**
 * Created by 14229 on 2020/1/22.
 */
public class BankCard {
    private double balance;

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public BankCard() {

    }

    public BankCard(double balance) {

        this.balance = balance;
    }

    public  void drawMoney(double money)throws BankException{
        if (balance-money>=0){
            System.out.println("取出："+money+" 还剩："+(balance-money));
            balance = balance-money;
        }else {
           throw new BankException("大哥 没那么多钱 咱就别装了");
        }
    }

    public double saveMoney(double money) throws BankException {
        if (money>5000){
            throw new BankException("大哥能不能少存点，这一下我算不过来");
        }else {
            System.out.println("存入成功  总有："+(balance+money));
            balance = balance+money;
            return balance+money;
        }
    }


}
